<template>
<div class="use-event-listener">
  <div>UseEventListener</div>
  <input ref="inputRef" type="text"><br/>
  <button @click="cleanup">清除input事件</button>
</div>
</template>

<script setup lang="ts">
import { ref } from "vue";
import { useEventListener } from "@vueuse/core";

defineOptions({
  name: "UseEventListener"
})
const inputRef = ref<HTMLInputElement | null>(null)
const cleanup = useEventListener(inputRef, 'input', (e) => {
  console.log(e.target.value)
})
</script>

<style scoped lang="css">
.use-event-listener {

}
</style>
